//
//  PywPayPwdModifyNewViewController.m
//  PywSdk
//
//  Created by smallwave on 16/8/12.
//  Copyright © 2016年 zero. All rights reserved.
//

#import "PywPayPwdModifyNewViewController.h"
#import "UILabel+Pyw.h"
#import "UIButton+Pyw.h"
#import "PywPasswordView.h"
#import "PywMasonry.h"

@interface PywPayPwdModifyNewViewController ()

@property (nonatomic, strong) UILabel           *propmtLabel;       // 提示信息
@property (nonatomic, strong) PywPasswordView   *pwdView;           // 密码输入框
@property (nonatomic, strong) UIButton          *resetBtn;          // 立即重设按钮

@end

@implementation PywPayPwdModifyNewViewController
KeyBoardHelper(110)

#pragma mark - Lift Cycle
- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setUp];
}
- (void)viewDidDisappear:(BOOL)animated{
    [self.pwdView clearText];
}
#pragma mark - prepareUI
- (void)setUp{
    self.title = @"修改交易密码";
    self.navigationItem.rightBarButtonItem = nil;
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    [self addSubviewAndLayoutSubviews];
}
- (void)addSubviewAndLayoutSubviews{
    [self.view addSubview:self.propmtLabel];
    
    self.pwdView.passwordBlock = ^(NSString *password){
        NSLog(@"%@",password);
    };
    [self.view addSubview:self.pwdView];
    [self.view addSubview:self.resetBtn];
    
    __weak typeof(self) wSelf = self;
    [self.propmtLabel mas_makeConstraints:^(PywMASConstraintMaker *make) {
        make.centerX.offset(0);
        make.width.equalTo(wSelf.view.mas_width).multipliedBy(0.85);
        make.top.equalTo(wSelf.view.mas_top).offset(80);
    }];
    
    [self.pwdView mas_makeConstraints:^(PywMASConstraintMaker *make) {
        make.centerX.offset(0);
        make.top.equalTo(wSelf.propmtLabel.mas_bottom).offset(20);
        make.width.equalTo(wSelf.propmtLabel.mas_width);
        make.height.equalTo(@40);
    }];
    
    [self.resetBtn mas_makeConstraints:^(PywMASConstraintMaker *make) {
        make.centerX.offset(0);
        make.top.equalTo(wSelf.pwdView.mas_bottom).offset(30);
        make.width.height.equalTo(wSelf.pwdView);
    }];

}
#pragma mark - Action
- (void)resetPwdAction{
    NSLog(@"%s",__FUNCTION__);
}
#pragma mark - Lazy
- (UILabel *)propmtLabel{
    if (!_propmtLabel) {
        _propmtLabel = [UILabel labelWithText:@"请输入新的交易密码"
                                textAlignment:NSTextAlignmentLeft
                                     fontSize:12
                                    textColor:[UIColor blackColor]];
    }
    return _propmtLabel;
}
- (PywPasswordView *)pwdView{
    if (!_pwdView) {
        _pwdView = [[PywPasswordView alloc] init];
        _pwdView.backgroundColor = [UIColor whiteColor];
        _pwdView.layer.cornerRadius = 10;
        _pwdView.layer.masksToBounds = YES;
        _pwdView.layer.borderWidth = 1;
        _pwdView.layer.borderColor = [UIColor grayColor].CGColor;
        _pwdView.elementCount = 6;
        _pwdView.elementMargin = 0;
        _pwdView.elementColor = [UIColor grayColor];
    }
    return _pwdView;
}
- (UIButton *)resetBtn{
    if (!_resetBtn) {
        _resetBtn = [UIButton buttonWithBackgroundColor:RGB(252, 177, 14, 1)
                                           cornerRadius:20
                                             titleColor:[UIColor whiteColor]
                                     titleLabelFontSize:18
                                                  title:@"立即修改"];
        
        [_resetBtn addTarget:self action:@selector(resetPwdAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _resetBtn;
}

@end
